<template>
    <div>
        <el-card class="box-card" shadow="never">
            <!--导航栏-->
            <el-breadcrumb separator-class="el-icon-arrow-right">
                <el-breadcrumb-item>系统设置</el-breadcrumb-item>
                <el-breadcrumb-item>网格员日志</el-breadcrumb-item>
            </el-breadcrumb>
            <!--分割线-->
            <div class="yx_line"></div>
            <el-row :gutter="10" style="margin-top:20px;">
                <el-col :span="6">
                  <el-date-picker
                        style="width:100%"
                        v-model="start_date"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="起始日期">
                      </el-date-picker>
                 </el-col>
                 <el-col :span="6">
                   <el-date-picker
                         style="width:100%"
                         v-model="end_date"
                         type="date"
                         value-format="yyyy-MM-dd"
                         placeholder="截止日期">
                       </el-date-picker>
                  </el-col>
                  <el-col :span='6'>
                     <el-select v-model="type" placeholder="基础数据类型" clearable>
                         <el-option label="房屋" value="1"></el-option>
                         <el-option label="人员" value="2"></el-option>
                         <el-option label="单位" value="3"></el-option>
                         <el-option label="医院" value="4"></el-option>
                         <el-option label="学校" value="5"></el-option>
                     </el-select>
                  </el-col>
            </el-row>
            <!--添加按钮  条件搜索区 总计24栏-->
            <el-row class="yx_el_row">
                <el-col>
                    <el-button type="success" plain @click="search">筛选</el-button>
                </el-col>
            </el-row>
            <el-table class="yx_table" border :data="list">
                <el-table-column prop="index" label="序号" width="100">
                </el-table-column>
                <el-table-column prop="operator" label="操作人" width="180">
                </el-table-column>
                <el-table-column prop="ip" label="ip地址" width="180">
                </el-table-column>
                <el-table-column prop="create_time" label="创建时间" width="180">
                </el-table-column>
                <el-table-column prop="type" label="基础数据类型" width="150">
                </el-table-column>
                <el-table-column prop="content" label="日志内容">
                </el-table-column>

            </el-table>
            <el-pagination class="yx_page"
                           background
                           @current-change="handle_current_change"
                           @size-change="handle_size_change"
                           :page-sizes="page_sizes"
                           :page-size="page_size"
                           layout="prev, pager, next,sizes, total"
                           :total="total_count">
            </el-pagination>
        </el-card>
    </div>
</template>

<script>
    export default {
        name: 'LogList',
        inject:['reload'],
        data() {
            return {
                start_date:'',
                end_date:'',
                type:'',
                current_page:1,
                page_size:20,
            }
        },
        methods: {
            //请求列表
            getList(){
                var send_data={
                    api_token:this.$store.getters.getSessionId,
                    current_page:this.current_page,
                    page_size:this.page_size,
                    start_date:this.start_date,
                    end_date:this.end_date,
                    type:this.type
                }
                this.$store.dispatch('loadLogList',send_data);
            },
            search(){
               this.current_page=1;
               this.$store.commit('setSearchLogType',this.type);
               this.getList();
            },
            //跳转页
            handle_current_change(current_page){
                //当前页码数
                this.current_page=current_page;
                this.getList();
            },
            //修改条数
            handle_size_change(page_size){
                this.current_page=1;
                this.page_size=page_size;
                this.getList();
            }
        },
        created() {
            this.getList();
        },
        computed:{
            list(){
                return this.$store.getters.getLogList;
            },
            total_count(){
                return this.$store.getters.getLogTotalCount;
            },
            page_sizes(){
                return this.$store.state.page_sizes;
            }
        }
    }
</script>

<style>
    @import url('../../assets/css/table.css');
</style>
